﻿using Microsoft.Practices.EnterpriseLibrary.Logging;
using Common.Logging;
using System.Collections.Generic;
namespace CookComputing.MetaWeblog
{
    public class MetaWeblog : XmlRpc.XmlRpcService, IMetaWeblog
    {
        private ILog log = LogManager.GetLogger(typeof(IMetaWeblog));
        public object editPost(string postid, string username, string password, Post post, bool publish)
        {
            log.Warn(string.Format(@"{0}
            {1}
{2}
{3}
{4}
{5} 
{6}
            ",
                postid,
                username,
                password,
                string.Join("|", post.categories),
                post.dateCreated.ToString(),
                post.title,
                publish));
            return "true";
        }

        public CategoryInfo[] getCategories(string blogid, string username, string password)
        {
            return new CategoryInfo[]{
           new CategoryInfo (){ categoryid ="1", description ="描述1", htmlUrl="htmlUrl1", rssUrl ="rss1",title ="标题1"},
              new CategoryInfo (){ categoryid ="2", description ="描述2", htmlUrl="htmlUrl1", rssUrl ="rss1",title ="标题2"},
                 new CategoryInfo (){ categoryid ="3", description ="描述3", htmlUrl="htmlUrl1", rssUrl ="rss1",title ="标题3"},
      
           };
        }

        public Post getPost(string postid, string username, string password)
        {
            var p = new Post();
            p.postid = postid;
            return p;

        }
        private static List<Post> posts = new List<Post>()
        {

        };
        public Post[] getRecentPosts(string blogid, string username, string password, int numberOfPosts)
        {
            return posts.ToArray();
        }

        public string newPost(string blogid, string username, string password, Post post, bool publish)
        {
            var p = new Post();
            p.postid = blogid;
            return p.title;
        }

        public UrlData newMediaObject(string blogid, string username, string password, FileData file)
        {
            throw new System.NotImplementedException();
        }
    }
}